package com.briup.cms.dao;

import com.briup.cms.bean.Inform;
import com.briup.cms.bean.extend.InformExtend;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface InformMapper {
    @Results ({
            @Result(column = "article_id", property = "articleId"),
            @Result(column = "user_id", property = "userId")
    }

    )

    @Select("select * from cms_inform")
    List<Inform> selectAll();

    @Insert("insert into cms_inform values(null,#{content},#{articleId},#{userId})")
    void insert(Inform inform);

    @Update("update cms_inform set content=#{content},article_id=#{articleId},user_id=#{userId} where id=#{id}")
     void update(Inform inform);

    @Delete("delete from cms_inform where id=#{id}")
    void delete(Long id);

    @Results({
            @Result(property = "articleTitle",column = "article_title")
    })
    @Select("select i.*,a.title as article_title from cms_inform i left join cms_article a on i.article_id = a.id")
    List<InformExtend> selectAllWithArticle();
}
